﻿<%@ Control Language="C#"
            AutoEventWireup="true"
            CodeFile="ConfirmDialog.ascx.cs"
            Inherits="UserControls_ConfirmDialog" %>
            
<asp:Panel ID="DialogConfirmPanel" runat="server"
    ToolTip="Mensaje de Confirmacion">
    <p>
        <span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
        <asp:Literal ID="MessageLiteral" runat="server"
            Text="Esta seguro que desea eliminar este registro?.">
        </asp:Literal>
        
    </p>
</asp:Panel>
<asp:HiddenField ID="CommandHiddenField" runat="server" />
<asp:HiddenField ID="ApplyToCssClassHiddenField" runat="server" Value="delete" />
<asp:HiddenField ID="ActionBeforeCloseHiddenField" runat="server" />
<asp:HiddenField ID="ActionBeforeOpenHiddenField" runat="server" />
<asp:HiddenField ID="ActionAfterOpenHiddenField" runat="server" />
<asp:HiddenField ID="ActionBeforeConfirmHiddenField" runat="server" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#<%= DialogConfirmPanel.ClientID %>").dialog({
            resizable: false,
            height: 180,
            modal: true,
            autoOpen: false,
            buttons: {
                'Si': function () {
                    if ($("#<%= ActionBeforeConfirmHiddenField.ClientID %>").val() != "")
                        eval($("#<%= ActionBeforeConfirmHiddenField.ClientID %>").val());
                    eval($("#<%= CommandHiddenField.ClientID %>").val());
                    $(this).dialog('close');
                },
                'No': function () {
                    $(this).dialog('close');
                }
            },
            beforeClose: function (event, ui) {
                if ($("#<%= ActionBeforeCloseHiddenField.ClientID %>").val() != "")
                    eval($("#<%= ActionBeforeCloseHiddenField.ClientID %>").val());
            }
        });

        $(".<%= ApplyToCssClass %>").each(function () {
            $(this).click(function () {
                if ($("#<%= ActionBeforeOpenHiddenField.ClientID %>").val() != "")
                    eval($("#<%= ActionBeforeOpenHiddenField.ClientID %>").val());
                if (!$("#aspnetForm").valid())
                    return false;
                $("#<%= DialogConfirmPanel.ClientID %>").dialog("open");
                $("#<%= CommandHiddenField.ClientID %>").val($(this).attr("href"));
                if ($("#<%= ActionAfterOpenHiddenField.ClientID %>").val() != "")
                    eval($("#<%= ActionAfterOpenHiddenField.ClientID %>").val());
                return false;
            });
        });

    });
    
</script>
